from django.db import models

# Create your models here.

class category(models.Model):
    id= models.AutoField(primary_key= True, name= 'id', editable= False)
    name= models.CharField(u'分类名称', max_length= 64, default= "")
    parent_id= models.IntegerField(u'上级目录ID', default= 0)
    enable= models.BooleanField(u'启用', default= 0)
    display_index= models.BooleanField(u'显示模式', default= 0)
    def __str__(self):
        return self.name
    class Meta:
        ordering= ["-id"]
        db_table= 'category'

class movie_list(models.Model):
    id= models.AutoField(primary_key= True, name= 'id', editable= False)
    name= models.CharField(u'片名', max_length= 128 , default= '')
    remark= models.TextField(u'备注', null= True, default= None)
    director= models.TextField(u'导演', null= True, default= None)
    performer= models.TextField(u'演员', null= True, default= None)
    number= models.IntegerField(u'集数', null= True, default= 0)
    category= models.ForeignKey(to= category, on_delete= models.DO_NOTHING)
    country= models.TextField(u'国家', null= True, default= None)
    language= models.TextField(u'语言', null= True, default= None)
    year= models.TextField(u'上映年份', null= True, default= None)
    last_update_time= models.DateTimeField(u'最后更新日期', auto_now= True)
    tag= models.TextField(u'标签', null= True, default= None)
    description= models.TextField(u'描述', null= True, default= None)
    cover= models.TextField(u'封面', null= True, default= None)
    alias= models.TextField(u'别名', null= True, default= None)
    enable= models.BooleanField(u'启用', default= 1)

    def __str__(self):
        return self.name
    class Meta:
        ordering= ["-last_update_time"]
        db_table= 'movie_list'

class movie_play_list(models.Model):
    id= models.AutoField(primary_key= True, name= 'id', editable= False)
    movie= models.ForeignKey(to= movie_list, on_delete= models.DO_NOTHING)
    play_url= models.TextField(u'播放地址')
    sources= models.CharField(u'片源', max_length= 50)
    p_index= models.CharField(u'描述', max_length= 25)
    spider_sources= models.CharField(u'采集源', max_length=50)
    spider_sources_index= models.IntegerField(u'采集源序号')

    def __str__(self):
        return self.name
    class Meta:
        ordering= ["-id"]
        db_table= 'movie_play_list'